package com.example.vv.model.self;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.vv.R;
import com.example.vv.frameWork.mvp.MvpFragment;
import com.example.vv.frameWork.sp.Userinfo;
import com.example.vv.frameWork.until.SharePUntitl;
import com.example.vv.model.login.LoginAct;
import com.example.vv.model.self.base.contract.SelfContract;
import com.example.vv.model.self.base.presenter.SelfPresenter;

import butterknife.BindView;
import butterknife.OnClick;

public class SelfFragment extends MvpFragment<SelfContract.View, SelfPresenter> implements SelfContract.View {
    @BindView(R.id.self_icon_image)
    ImageView selfIconImage;
    @BindView(R.id.self_name_text)
    TextView selfNameText;
    @BindView(R.id.self_login)
    RelativeLayout selfLogin;
    @BindView(R.id.self_l1)
    LinearLayout selfL1;
    @BindView(R.id.self_l2)
    LinearLayout selfL2;
    @BindView(R.id.self_l3)
    LinearLayout selfL3;
    @BindView(R.id.self_l4)
    LinearLayout selfL4;
    @BindView(R.id.self_l5)
    LinearLayout selfL5;
    @BindView(R.id.self_l6)
    LinearLayout selfL6;
    @BindView(R.id.self_l7)
    LinearLayout selfL7;
    @BindView(R.id.self_l8)
    LinearLayout selfL8;
    private Userinfo userBean;
    private Userinfo bean;

    @Override
    public int initLayout() {
        return R.layout.fragment_self;
    }

    @Override
    public SelfPresenter initPresenter() {
        return new SelfPresenter();
    }

    @Override
    public void initView() {
        if (bean != null) {
            Glide.with(this)
                    .load(bean.getImageUrl())
                    .circleCrop()
                    .into(selfIconImage);
            selfNameText.setText(bean.getName());
        }
    }

    @Override
    public void initData() {
        bean = SharePUntitl.getUserBean(mActivity);
    }

    @Override
    public void doBusiness() {

    }

    @Override
    public View titleBar() {
        return null;
    }

    @Override
    public Context getMContext() {
        return getContext();
    }

    @OnClick(R.id.self_login)
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.self_login:
                SharePUntitl.clearUserInfo(getActivity());
                //登录
                startActivity(new Intent(getMContext(), LoginAct.class));
                break;
        }
    }
}
